<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of user
 *
 * @author Dmitry
 */
class Controller_User extends Controller_Action {
    //put your code here
    function index()
    {
        echo 'Ви увійшли, як <b>' . $_COOKIE['name'] . '</b>!' ;
    }
    
    function register()
    {
        if(isset ($_POST['login'])) 
        {
            $this->registry->get('view')->set('login', $_POST['login']) ; 
        }
        if(isset ($_POST['pass'])) 
        {
            $this->registry->get('view')->set('pass', $_POST['pass']) ;
        }
        if(isset ($_POST['email'])) 
        {
            $this->registry->get('view')->set('email', $_POST['email']) ;
        }
        $this->registry->get('view')->show('register') ;
    }
    
    function auth()
    {
        
        if(isset ($_POST['login'])) 
        {
            $this->registry->get('view')->set('login', $_POST['login']) ; 
        }
        if(isset ($_POST['pass'])) 
        {
            $this->registry->get('view')->set('pass', $_POST['pass']) ;
        }
        $this->registry->get('view')->show('login') ;

    }
    
    function isAuth()
    {
        $this->registry->get('view')->show('in') ;
    }
    
    function pass()
    {
        echo 'Не вірний пароль!' ;
        $this->registry->get('view')->show('in') ;
    }
    
    function out()
    {
                setcookie("ID", "", time() - 3600*24*30*12, "/");
                setcookie("hash", "", time() - 3600*24*30*12, "/");
                setcookie("name", "", time()- 3600*24*30, "/");
    }
}

?>
